import { Button } from 'antd';
import api from '../../api';
import { useNavigate } from 'react-router-dom';

export default function ThirdPartyLogin() {
  const navigate = useNavigate();

  const handleGiteeLogin = async () => {
    try {
      const response = await api.get('/gitee/auth');
      window.location.href = response.data.authURL;
    } catch (error) {
      console.error('获取Gitee授权链接失败:', error);
    }
  };

  return (
    <div style={{ textAlign: 'center', marginTop: 20 }}>
      <Button 
        type="primary" 
        style={{ backgroundColor: '#c71d23', borderColor: '#c71d23' }}
        onClick={handleGiteeLogin}
      >
        Gitee账号登录
      </Button>
    </div>
  );
}